package cn.iotab.iotkit.transport.api.common.message.msg;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.commons.lang3.StringUtils;

@Getter
@Setter
@ToString
public class CommonPayload implements Payload {
    private String productKey;
    private String deviceId;
    private String payload;

    public static CommonPayload of(String productKey, String deviceId, String payload) {
        if (StringUtils.isBlank(productKey)) {
            throw new NullPointerException("productKey is blank");
        }
        if (StringUtils.isBlank(deviceId)) {
            throw new NullPointerException("deviceId is blank");
        }
        if (StringUtils.isBlank(payload)) {
            throw new NullPointerException("payload is blank");
        }
        CommonPayload ret = new CommonPayload();
        ret.productKey = productKey;
        ret.deviceId = deviceId;
        ret.payload = payload;
        return ret;
    }
}
